package com.zh.work.service.platform.trans.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.zh.work.dao.platform.trans.NotifyOfficeTransMapper;
import com.zh.work.entity.trans.NotifyOfficeTransEntity;
import com.zh.work.service.platform.trans.NotifyOfficeTransService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * code is far away from bug with the animal protecting
 * ┏┓　　　┏┓
 * ┏┛┻━━━┛┻┓
 * ┃　　　　　　　┃
 * ┃　　　━　　　┃
 * ┃　┳┛　┗┳　┃
 * ┃　　　　　　　┃
 * ┃　　　┻　　　┃
 * ┃　　　　　　　┃
 * ┗━┓　　　┏━┛
 * 　　┃　　　┃神兽保佑
 * 　　┃　　　┃代码无BUG！
 * 　　┃　　　┗━━━┓
 * 　　┃　　　　　　　┣┓
 * 　　┃　　　　　　　┏┛
 * 　　┗┓┓┏━┳┓┏┛
 * 　　　┃┫┫　┃┫┫
 * 　　　┗┻┛　┗┻┛
 *
 * @Description: 公众号消息设置业务逻辑实现层
 * @Author: Li.HuiNeng
 * @Create in: 2019/09/12
 * @Version: 1.0.1
 */
@Service
public class NotifyOfficeTransServiceImpl extends ServiceImpl<com.zh.work.dao.platform.trans.NotifyOfficeTransMapper, NotifyOfficeTransEntity> implements NotifyOfficeTransService {

    @Autowired
    private NotifyOfficeTransMapper mapper;


    @Override
    public IPage<NotifyOfficeTransEntity> selectNotifyOfficeTransPages(Page<NotifyOfficeTransEntity> page, NotifyOfficeTransEntity param) {
        return this.mapper.selectPage(
                page,
                new QueryWrapper<NotifyOfficeTransEntity>().lambda()
                        .eq(StringUtils.isNotEmpty(param.getBranchNo()), NotifyOfficeTransEntity::getBranchNo, param.getBranchNo())
                        .like(StringUtils.isNotEmpty(param.getMerchNo()), NotifyOfficeTransEntity::getMerchNo, param.getMerchNo())
                        .between(ObjectUtils.allNotNull(param.getStartDate(), param.getEndDate()),
                                NotifyOfficeTransEntity::getAddTime, param.getStartDate(), param.getEndDate())
                        .like(StringUtils.isNotEmpty(param.getOrderNo()), NotifyOfficeTransEntity::getOrderNo, param.getOrderNo())
                        .eq(Objects.nonNull(param.getBizType()), NotifyOfficeTransEntity::getBizType, param.getBizType())
                        .eq(Objects.nonNull(param.getNotifyStatus()), NotifyOfficeTransEntity::getNotifyStatus, param.getNotifyStatus())
                        .eq(Objects.nonNull(param.getTransType()), NotifyOfficeTransEntity::getTransType, param.getTransType())
        );
    }

    @Override
    public List<Map<String, String>> getOfficeStatistic(NotifyOfficeTransEntity param) {
        return mapper.getOfficeStatistic(param);
    }

}
